classes = [
    {"name": "n_1", "age": 24, "grade": "A"},
    {"name": "n_2", "age": 23, "grade": "B"},
    {"name": "n_3", "age": 28, "grade": "A"},
    {"name": "n_4", "age": 24, "grade": "A"},
    {"name": "n_5", "age": 25, "grade": "C"},
    {"name": "n_6", "age": 21, "grade": "D"},
    {"name": "n_7", "age": 27, "grade": "A"},
]

# 以grade进行排序
classes.sort(key=lambda x: x["grade"])
print(classes)

# 通过filter语句来筛选出Grade为A的同学
f = filter(lambda x: x["grade"] == "A",classes)
list(f)

# age加1
def age_add(n):
    n["age"] += 1
    return n
m = map(age_add,classes)
list(m)

# 递归函数构造斐波那契数列
def F(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return F(n-2)+ F(n-1)
for n in range(10):
    print (F(n),end=" ")
